<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TestRuntime>true</TestRuntime>
    <TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
    <MainLibraryFileName>Android.Device_Emulator.gRPC.Test.dll</MainLibraryFileName>
    <ExpectedExitCode>42</ExpectedExitCode>

    <MonoForceInterpreter>false</MonoForceInterpreter>
    <RunAOTCompilation>true</RunAOTCompilation>
    <ForceAOT>true</ForceAOT>
    <AOTWithLibraryFiles>true</AOTWithLibraryFiles>

    <PublishTrimmed>true</PublishTrimmed>
    <EnableAggressiveTrimming>true</EnableAggressiveTrimming>

    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <!-- Disable CS8981 because the generated code from the protobuf files contains classes with lowercase names -->
    <!-- Disable SYSLIB0039 because the tests intentionally use TLS 1.0 and 1.1 -->
    <NoWarn>CS8981;SYSLIB0039</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Program.cs" />
  </ItemGroup>

  <!-- Based on grpc-dotnet's testassets/InteropTestsClient/InteropTestsClient.csproj -->
  <ItemGroup>
    <!-- Required for QUIC & HTTP/3 in .NET 6 - https://github.com/dotnet/runtime/pull/55332 -->
    <RuntimeHostConfigurationOption Include="System.Net.SocketsHttpHandler.Http3Support" Value="true" />

    <Compile Include="$(MSBuildProjectDirectory)\grpc-dotnet\testassets\Shared\*.cs" />
    <Compile Include="$(MSBuildProjectDirectory)\grpc-dotnet\test\Shared\HttpEventSourceListener.cs" />

    <Protobuf
      Include="$(MSBuildProjectDirectory)\grpc-dotnet\testassets\Proto\grpc\testing\*.proto"
      ProtoRoot="$(MSBuildProjectDirectory)\grpc-dotnet\testassets\Proto\grpc\testing\"
      GrpcServices="Client" />

    <PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufVersion)" />
    <PackageReference Include="Grpc.Auth" Version="$(GrpcAuthVersion)" />
    <PackageReference Include="Grpc.Core" Version="$(GrpcCoreVersion)" PrivateAssets="All" />
    <PackageReference Include="Grpc.Net.Client" Version="$(GrpcDotnetClientVersion)" />
    <PackageReference Include="Grpc.Tools" Version="$(GrpcToolsVersion)" PrivateAssets="All" />
  </ItemGroup>

  <Target Name="BuildServerDockerImage" AfterTargets="Build" Condition="'$(BuildGrpcServerDockerImage)' == 'true'">
    <Exec Command="cp $(RepoRoot)eng/Versions.props grpc-dotnet/testassets/InteropTestsWebsite/" />
    <Exec Command="docker build -t grpc-server:latest grpc-dotnet/testassets/" />
    <Exec Command="mkdir -p $(ArtifactsObjDir)/grpcserver/docker/" />
    <Exec Command="docker save -o $(ArtifactsObjDir)/grpcserver/docker/grpcserver.tar grpc-server:latest" />
  </Target>
</Project>
